package chapter16;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * Description:
 *
 * @author lzy
 * @create 2018-04-20 下午3:45
 */
@Controller
@RequestMapping("/advice")
public class AdviceController {
    private static final Logger LOGGER = LoggerFactory.getLogger(AdviceController.class);

    @RequestMapping("/test")
    @ResponseBody
    public Map<String, Object> testAdvice(Date date, Model model) {
        Map<String, Object> map = new HashMap<>();
        map.put("project_name", model.asMap().get("projectName"));
        map.put("date", date);
        return map;
    }

    @RequestMapping("/exception")
    public void exception() {
        throw new RuntimeException("测试异常跳转");
    }
}
